package com.woniuxy.store.app.apiImpl;

import cn.hutool.core.bean.BeanUtil;
import com.woniuxy.member.client.CommentManageClient;
import com.woniuxy.member.client.CommentQueryClient;
import com.woniuxy.member.client.param.CommentInfoSearchParams;
import com.woniuxy.member.client.result.CommentInfoClientDto;
import com.woniuxy.store.app.util.StoreIdUtil;
import com.woniuxy.store.client.CommentClient;
import com.woniuxy.store.client.param.commentParam.CommentInfoSearchParamss;
import common.WoniuPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import result.Result;

import javax.validation.Valid;

@RestController
@RequestMapping("/store/order")
public class CommentClientImpl implements CommentClient {
    @Autowired
    private CommentQueryClient commentQueryClient;
    @Autowired
    private CommentManageClient commentManageClient;
    @Override
    public Result getStoreCommentInfo(@Valid CommentInfoSearchParamss commentInfoSearchParamss) {
        CommentInfoSearchParams commentInfoSearchParams = BeanUtil.toBean(commentInfoSearchParamss, CommentInfoSearchParams.class);
        commentInfoSearchParams.setStoreId(StoreIdUtil.getFromToken());
        Result<WoniuPage<CommentInfoClientDto>> storeCommentInfo = commentQueryClient.getStoreCommentInfo(commentInfoSearchParams);
        return storeCommentInfo;
    }

    @Override
    public Result delStoreComment(Integer commentId) {
        Result result = commentManageClient.delStoreComment(StoreIdUtil.getFromToken(), commentId);

        return result;
    }
}
